<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
     var num = prompt("请输入数字！");

    for (var i = 1;i<=num;i++){
         for (var j=1;j<=num-i;j++){
            document.write("&nbsp");
         }

            for (var j=1;j<=i;j++) {
                document.write("&nbsp"+"*");
            }
              document.write("<br>");

    }
    for (var i=1;i<=num-1;i++){
        for (var j=1;j<=i;j++){
            document.write("&nbsp");
        }
        for (var j=1;j<=num-i;j++){
            document.write("&nbsp"+"*");
        }
        document.write("<br>");
    }


     alert(num);

</script>

</body>
</html>